package com.collection.treesets;

import java.util.TreeSet;

public class RemoveSpecifiedElementFromTreeSetExample {
	public static void main(String[] args) {
		 
	    //create object of TreeSet
	    TreeSet tSet = new TreeSet();
	   
	    //add elements to TreeSet object
	    tSet.add(new Integer("1"));
	    tSet.add(new Integer("2"));
	    tSet.add(new Integer("3"));
	   
	    System.out.println("TreeSet before removal : " + tSet);
	   
	    /*
	      To remove an element from Java TreeSet object use,
	      boolean remove(Object o) method.
	      This method removes an element from TreeSet if it is present and returns
	      true. Otherwise remove method returns false.
	    */
	   
	    boolean blnRemoved = tSet.remove(new Integer("2"));
	    System.out.println("Was 2 removed from TreeSet ? " + blnRemoved);
	   
	    System.out.println("TreeSet after removal : " + tSet);
	  }
}
